package com.ruoyi.controller;

import com.ruoyi.common.Result;
import com.ruoyi.entity.DecorationTag;
import com.ruoyi.service.DecorationTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 装饰画标签关联控制器
 * 处理装饰画与标签关联的HTTP请求
 *
 * @author ruoyi
 */
@Api(tags = "装饰画标签关联管理接口")
@RestController
@RequestMapping("/api/decoration/tag")
public class DecorationTagController {
    
    @Autowired
    private DecorationTagService decorationTagService;
    
    /**
     * 获取装饰画关联的标签列表
     *
     * @param decorationId 装饰画ID
     * @return 标签关联列表
     */
    @ApiOperation("获取装饰画关联的标签列表")
    @GetMapping("/list/{decorationId}")
    public Result<List<DecorationTag>> listTagsByDecorationId(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId) {
        List<DecorationTag> tags = decorationTagService.listTagsByDecorationId(decorationId);
        return Result.success(tags);
    }
    
    /**
     * 为装饰画添加标签
     *
     * @param decorationId 装饰画ID
     * @param tagId 标签ID
     * @return 添加结果
     */
    @ApiOperation("为装饰画添加标签")
    @PostMapping("/{decorationId}/{tagId}")
    public Result<Boolean> addTag(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("标签ID") @PathVariable Integer tagId) {
        boolean success = decorationTagService.addTag(decorationId, tagId);
        return Result.success(success);
    }
    
    /**
     * 移除装饰画的标签
     *
     * @param decorationId 装饰画ID
     * @param tagId 标签ID
     * @return 移除结果
     */
    @ApiOperation("移除装饰画的标签")
    @DeleteMapping("/{decorationId}/{tagId}")
    public Result<Boolean> removeTag(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("标签ID") @PathVariable Integer tagId) {
        boolean success = decorationTagService.removeTag(decorationId, tagId);
        return Result.success(success);
    }
    
    /**
     * 批量添加装饰画标签
     *
     * @param decorationId 装饰画ID
     * @param tagIds 标签ID列表
     * @return 添加结果
     */
    @ApiOperation("批量添加装饰画标签")
    @PostMapping("/{decorationId}/batch")
    public Result<Boolean> batchAddTags(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("标签ID列表") @RequestBody List<Integer> tagIds) {
        boolean success = decorationTagService.batchAddTags(decorationId, tagIds);
        return Result.success(success);
    }
    
    /**
     * 批量移除装饰画标签
     *
     * @param decorationId 装饰画ID
     * @param tagIds 标签ID列表
     * @return 移除结果
     */
    @ApiOperation("批量移除装饰画标签")
    @DeleteMapping("/{decorationId}/batch")
    public Result<Boolean> batchRemoveTags(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("标签ID列表") @RequestBody List<Integer> tagIds) {
        boolean success = decorationTagService.batchRemoveTags(decorationId, tagIds);
        return Result.success(success);
    }
} 